//
//  LoginViewController.m
//  HappyBug
//
//  Created by liulei on 2018/10/20.
//  Copyright © 2018年 www.hc.com.cn. All rights reserved.
//

#import "LoginViewController.h"
#import "LoginChangeView.h"

@interface LoginViewController ()

@end

@implementation LoginViewController{
    
    UITextField *userTextField;
    
    UITextField *pwTextField;
    
    UIView *buttomView;
    UIButton *changeBt;
    UIButton *wxbutton;
    UIButton *qqbutton;
    
    BOOL loginFlag;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //灰色
    [self.view setBackgroundColor:[UIColor colorWithRed:211/255.0 green:211/255.0 blue:211/255.0 alpha:2]];
    
    [self initView];
    
}
-(void)loginback{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
-(void)initView{
    //返回按钮
    UIButton *back=[[UIButton alloc]init];
    [back setTitle:@" < " forState:UIControlStateNormal];
    [back setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [back addTarget:self action:@selector(loginback) forControlEvents:UIControlEventTouchDragInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:back];
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:211/255.0 green:211/255.0 blue:211/255.0 alpha:2];
    
    //圆角图片
    CGFloat navHei= self.navigationController.navigationBar.frame.size.height;
    //image 居中
    UIButton *headPhoto=[[UIButton alloc]initWithFrame:CGRectMake((self.view.frame.size.width-70)/2, navHei+30, 70, 70)];

    //请输入用户名/手机号
    userTextField =[[UITextField alloc]init];
    userTextField.frame=CGRectMake(2, headPhoto.frame.size.height+headPhoto.frame.origin.y+20, self.view.frame.size.width-2, 50);
    userTextField.placeholder=@"请输入用户名/手机号";
    [userTextField setBackgroundColor:[UIColor whiteColor]];
    [userTextField setBorderStyle:UITextBorderStyleRoundedRect];
    [self.view addSubview:userTextField];
    
    
    pwTextField =[[UITextField alloc]init];
    pwTextField.frame=CGRectMake(2, userTextField.frame.origin.y+userTextField.frame.size.height+20, self.view.frame.size.width-2, 50);
    pwTextField.placeholder=@"密码";
    [pwTextField setBackgroundColor:[UIColor whiteColor]];
    
    [pwTextField setBorderStyle:UITextBorderStyleRoundedRect];
    
    [self.view addSubview:pwTextField];
    
    
    UIButton *loginButton=[[UIButton alloc]init];
    loginButton.frame=CGRectMake(40, self.view.frame.size.height/2, self.view.frame.size.width-40*2, 45);
    [loginButton setBackgroundColor:[UIColor colorWithRed:50/255.0 green:189/255.0 blue:170/255.0 alpha:1]];
    loginButton.layer.cornerRadius=3;
    loginButton.layer.borderWidth=0.8;
    [loginButton setTitle:@"登录" forState:UIControlStateNormal];
    [self.view addSubview:loginButton];
    
    
    //忘记密码。注册
    UILabel *forgetBt =[[UILabel alloc]init];
    forgetBt.frame=CGRectMake(40, loginButton.frame.size.height+loginButton.frame.origin.y+10, 100, 30);
    forgetBt.text=@"忘记密码";
    forgetBt.textAlignment=NSTextAlignmentLeft;
    forgetBt.font=[UIFont systemFontOfSize:12];
    [self.view addSubview:forgetBt];
    
    
    //忘记密码。注册
    UILabel *registBt =[[UILabel alloc]init];
    registBt.frame=CGRectMake(self.view.frame.size.width-140,loginButton.frame.size.height+loginButton.frame.origin.y+10, 100, 30);
    registBt.text=@"自主注册";
    registBt.textAlignment=NSTextAlignmentRight;
    registBt.font=[UIFont systemFontOfSize:12];
    [self.view addSubview:registBt];
    
    
    buttomView=[[UIView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-40,[UIScreen mainScreen].bounds.size.width, 100)];
    [self.view addSubview:buttomView];
    
    
    //changeBt
    UIButton *changeBt=[[UIButton alloc]init];
    changeBt.frame =CGRectMake(30,0, self.view.frame.size.width-60, 30);
    changeBt.font=[UIFont systemFontOfSize:12];
    [changeBt setTitleColor:[UIColor colorWithRed:50/255.0 green:189/255.0 blue:170/255.0 alpha:1] forState:UIControlStateNormal];
    
    [changeBt setTitle:@"--切换登录方式--" forState:UIControlStateNormal];
    [changeBt addTarget:self action:@selector(bttonClick) forControlEvents:UIControlEventTouchUpInside];
    [buttomView  addSubview:changeBt];
    
    
    
    qqbutton =[[UIButton alloc]init];
    qqbutton.frame=CGRectMake((self.view.frame.size.width-40-40-20)/2, changeBt.frame.origin.y+changeBt.frame.size.height+10, 30, 30);
    [qqbutton setBackgroundImage:[UIImage imageNamed:@"img0"] forState:UIControlStateNormal];
    [buttomView addSubview:qqbutton];
    
    
    wxbutton =[[UIButton alloc]init];
    wxbutton.frame=CGRectMake((self.view.frame.size.width-40-40-20)/2+60, changeBt.frame.origin.y+changeBt.frame.size.height+10, 30, 30);
    [wxbutton setBackgroundImage:[UIImage imageNamed:@"img1"] forState:UIControlStateNormal];
    [buttomView addSubview:wxbutton];
    
    loginFlag=false;
    
}


- (void)headclick {
    
    NSLog(@"点击图片了");
}

-(void)bttonClick{
    //动画开始
    [UIView beginAnimations:nil context:nil];
    //动画时间
    [UIView setAnimationDuration:0.5];
    //动画内容
    if(!loginFlag){
        buttomView.frame=CGRectMake(0, [UIScreen mainScreen].bounds.size.height-100, [UIScreen mainScreen].bounds.size.width, 100);
    }else{
        buttomView.frame=CGRectMake(0, [UIScreen mainScreen].bounds.size.height-40, [UIScreen mainScreen].bounds.size.width, 100);
    }
    //按钮两次点击事件触发不同的两次事件处理
    loginFlag=!loginFlag;
    //动画结束
    [UIView commitAnimations];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
